home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / createBookmark.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.3 KB  |  115 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  October 25, 1996
  22. //  Author:         mm
  23. //
  24. //  Description:
  25. //      This a helper script which will create a new bookmark
  26. //        containing the objects displayed within an editor.
  27. //
  28. //  Input Arguments:
  29. //      The name of the editor to modify
  30. //        The type of the bookmark to create
  31. //
  32. //        Whether a dialog should be popped to prompt the
  33. //        user for a bookmark name or not.
  34. //
  35. //  Return Value:
  36. //      None.
  37. //
  38.  
  39. global proc
  40. createBookmark (string $editor, string $type, int $popDialog)
  41. {
  42.     // The default base name for bookmarks
  43.     //
  44.     string $defaultBaseName = "Bookmark";
  45.  
  46.     // Make sure the editor exists
  47.     //
  48.     if (!`editor -exists $editor`) {
  49.         error "Editor not found";
  50.     }
  51.  
  52.     // First, find out what is connected to this editor
  53.     //
  54.     string $mainListConnection = `editor -query -mainListConnection $editor`;
  55.     if ($mainListConnection == "") {
  56.         if (`modelEditor -exists $editor`) {
  57.             $mainListConnection = "activeList";
  58.         }
  59.         else {
  60.             error "No objects to bookmark";
  61.         }
  62.     }
  63.  
  64.     // Now create a new bookmark, and add all of the objects to it
  65.     //
  66.     string $objects[];
  67.     // If this is a model editor and it has an objectSet then bookmark those members
  68.     //
  69.     int $foundObjects = false;
  70.     if (`modelEditor -exists $editor`) {
  71.         string $objectSet = `modelEditor -query -viewObjects $editor`;
  72.         if ($objectSet != "") {
  73.             $objects = `sets -query $objectSet`;
  74.             $foundObjects = true;
  75.         }
  76.     }
  77.     if (!$foundObjects) {
  78.         $objects = `selectionConnection -query -object $mainListConnection`;
  79.     }
  80.     if (size ($objects) > 0) {
  81.         // Create a bookmark set and get its suggested name
  82.         //
  83.         string $bookmark = `sets -text $type -name $defaultBaseName`;
  84.         if( $popDialog ) {
  85.             // Let the user name the bookmark
  86.             //
  87.             string $response = `promptDialog
  88.                 -title "Create Bookmark"
  89.                 -message "Bookmark Name:"
  90.                 -text $bookmark
  91.                 -button "OK"
  92.                 -button "Cancel"
  93.                 -defaultButton "OK"
  94.                 -cancelButton "Cancel"
  95.                 -dismissString "Cancel"`;
  96.             if ($response == "OK") {
  97.                 //
  98.                 // If the user is happy, then add the bookmark
  99.                 //
  100.                 sets -addElement $bookmark $objects;
  101.                 string $name = `promptDialog -query -text`;
  102.                 rename $bookmark $name;
  103.             }
  104.             else {
  105.                 // Otherwise delete the bookmark set
  106.                 //
  107.                 delete $bookmark;
  108.             }
  109.         }
  110.     }
  111.     else {
  112.         warning "No objects to bookmark";
  113.     }
  114. }
  115.